package calorie.com.calorie.contact;

import android.content.Context;


import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.util.ToastUtils;


import calorie.com.calorie.api.ApiService;
import calorie.com.calorie.constant.Constant;
import calorie.com.calorie.request.RecordRequest;
import calorie.com.calorie.response.ChargeDrawRecordResponce;
import retrofit2.Call;
import retrofit2.Response;

public class ChargeDrawRecordContact {
    public static class ChargeDrawRecordPresent extends BasePresent<IChargeDrawRecordView> {
        public void queryRecordList(Context context,int pageNo,int type){
            ApiService service= ServiceGenerator.createService(ApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            RecordRequest request=new RecordRequest(userId,pageNo,type);
            service.chargeDrawCoinRecord(request).enqueue(new NetCallBack<ChargeDrawRecordResponce>() {
                @Override
                public void onSuccess(Call<ChargeDrawRecordResponce> call, Response<ChargeDrawRecordResponce> response) {
                    if (getView()!=null){
                        getView().getRecordListData(response);
                    }
                }

                @Override
                public void onFailed() {
                    //ToastUtils.showLongToast(context,"网络请求异常");
                }
            });
        }
    }
    public interface IChargeDrawRecordView extends IBaseView {
        void getRecordListData(Response<ChargeDrawRecordResponce> response);
    }
}
